<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="head.jsp" %>
<meta charset="utf-8">
<div class="container">
	<div class="row clearfix">
	<div class="col-md-12 column">
			<div class="page-header">
				<h1>
					想对心里TA说的话
				</h1>
			</div>
				
				<div class="form-group">
					 <label for="inputEmail3" class="col-sm-2 control-label">你的昵称</label>
					<div class="col-sm-10">
						<input type="text" class="form-control" id="userName" />
					</div>
				</div>
				<div class="form-group">
					 <label for="inputPassword3" class="col-sm-2 control-label">表白内容</label>
					<div class="col-sm-10">
						<textarea id="content" class="form-control" rows="3"></textarea>
					</div>
				</div>
				
				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
						 <button type="submit" class="btn btn-default addLove">发布</button>
					</div>
				</div>
		</div>
		<div class="col-md-12 column">
<table class="table">
	<caption>表白墙</caption>
	<thead>
		<tr>
			<th>昵称</th>
			<th>日期</th>
			<th>内容</th>
		</tr>
	</thead>
	<tbody id="tbScanData">
	<c:forEach items="${loveShows }" var="info">
		<tr>
			<td>${info.title }</td>
			<td>${info.addTime }</td>
			<td>${info.content }<br/><br/>来自-${info.ipregion }-的网友</td>
		</tr>
	</c:forEach>
	</tbody>
</table>
</div>
</div>
</div>
<input type="hidden" id="pathId" value="<%=request.getContextPath() %>">
<script>
$(".addLove").click(function(){
	var userName=$("#userName").val();
	var content=$("#content").val();
	if(userName==""){
		alert("昵称不能为空");
		return;
	}
	if(content==""){
		alert("内容不能为空");
		return;
	}
	$.ajax({ 
		   type: "post", 
		   url: $("#pathId").val()+"/img/addLoveShow",
		   data: {"nickname":userName,"content":content},
		   cache:false, 
		   async:false, 
		   success: function(xmlobj){ 
			   window.location.reload()
			 /* //添加数据到 table 第一行
			 var html="<tr><td></td><td></td><td></td></tr>";
		     $("#tbScanData").prepend(row); */
		   } 

		});
});
</script>